package fctuc.dei.myTwitter.client;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import javax.swing.SwingUtilities;

import fctuc.dei.myTwitter.com.Connection;
import fctuc.dei.myTwitter.com.Message;
import fctuc.dei.myTwitter.com.RMIClientListener;

public class RMIClientListenerImpl implements RMIClientListener {
    private MyTwitterClient myClient;
    private Connection conn;

    public RMIClientListenerImpl(MyTwitterClient client, Connection c) throws RemoteException {
        UnicastRemoteObject.exportObject(this);
        this.conn = c;
        this.myClient = client;
    }   
    public void handleMessage(Message m) throws RemoteException {
        final Message mt = m;

        Runnable handleMessage = new Runnable() {    
                public void run() {
                    conn.receive(mt);
                }};

        SwingUtilities.invokeLater(handleMessage);
    }
}